package wortubung.inflection;

import wortubung.core.LANG;

public enum PERSON {
       // fr         de           es                          it                   la
	S1( "je",        "ich",       "yo",                       "io",                "ego" ),
	S2( "tu",        "du",        "tú",                       "tu",                "tu"  ),
	S3( "il/elle",   "er/sie/es", "él/ella/usted",            "lui/lei/esso/essa", null  ),
	P1( "nous|n.",   "wir",       "nosotros/nosotras|nos.",   "noi",               "nos" ),
	P2( "vous|v.",   "ihr",       "vosotros/vosotras|vos.",   "voi",               "vos" ),
	P3( "ils/elles", "sie",       "ellos/ellas/ustedes|ell.", "loro/essi/esse",    null  );
	
	private String[] indigenousNames;
	private String[] indigenousShortNames;

	private PERSON(String... indigenousNames) {
		this.indigenousNames = indigenousNames;
		this.indigenousShortNames = new String[indigenousNames.length];
		for (int i=indigenousNames.length-1; i>=0; --i) {
			if (indigenousNames[i] == null)
				continue;
			String[] sa = indigenousNames[i].split("\\|");
			this.indigenousNames[i] = sa[0];
			this.indigenousShortNames[i] = sa[(sa.length > 1) ? 1 : 0];
			this.indigenousShortNames[i] = this.indigenousShortNames[i].split("/")[0];
		}
	}

	private int getLangIndex(LANG lang) {
		switch(lang) {
		case fr: return 0;
		case de: return 1;
		case es: return 2;
		case it: return 3;
		case la: return 4;
		default: return -1;
		}
	}

	public String getName(LANG lang) {
		return indigenousNames[getLangIndex(lang)];
	}

	public String getShortName(LANG lang) {
		return indigenousShortNames[getLangIndex(lang)];
	}

	public static String[] getNames(LANG lang) {
		PERSON[] a = values();
		String[] ret = new String[a.length];
		for (int i=0; i<a.length; ++i)
			ret[i] = a[i].getName(lang);
		return ret;
	}

	public static String[] getShortNames(LANG lang) {
		PERSON[] a = values();
		String[] ret = new String[a.length];
		for (int i=0; i<a.length; ++i)
			ret[i] = a[i].getShortName(lang);
		return ret;
	}

}
